class Solution {
    public int[] plusOne(int[] digits) {

        int len = digits.length;
        int flag = 0;
        int i = 0;
        for(i = len-1;i>=0;i--) {
            if(digits[i] != 9) {
                digits[i] += 1;
                return digits;
            }else {
                digits[i] = 0;
            }
        }
        int[] newarr = new int[len+1];
        newarr[0] = 1;
        return newarr;


    }
}